package com.magiccompass.alipay.barcode.entity;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Calendar;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "TD_MERCHANT_TRANSACTION_DETAIL")
@DynamicUpdate(value= true)
public class MerchantTransactionDetail {
	@Id
	@Column(name = "ID")
	@GeneratedValue
	private Integer id;
	
	@ManyToOne
	@JoinColumn(name="merchant_transaction_id")
	private MerchantTransaction merchantTransaction;
	
	@ManyToOne(cascade=CascadeType.REFRESH,fetch= FetchType.EAGER)
	@JoinColumn(name="product_id", nullable=false)
	private ProductInfo product;
	
	@Column(name = "quantity",length=3, nullable=false)
	private Integer quantity=1;
	
	@Column(name = "amount", nullable=false,precision=12, scale=2)
	private BigDecimal amount;
    
	@Column(name = "create_by", nullable=false)
	private Integer createBy;
	
	@Column(name = "create_time", nullable=false)
	private Timestamp createTime = new Timestamp(Calendar.getInstance().getTimeInMillis());

	@Column(name = "del_flag")
	private String delFlag = "F";
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public Integer getCreateBy() {
		return createBy;
	}
	public void setCreateBy(Integer createBy) {
		this.createBy = createBy;
	}
	public Timestamp getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}
	
	public String getDelFlag() {
		return delFlag;
	}
	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}
	public BigDecimal getAmount() {
		return amount;
	}
	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}
	public ProductInfo getProduct() {
		return product;
	}
	public void setProduct(ProductInfo product) {
		this.product = product;
	}
	public Integer getQuantity() {
		return quantity;
	}
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}
	public MerchantTransaction getMerchantTransaction() {
		return merchantTransaction;
	}
	public void setMerchantTransaction(MerchantTransaction merchantTransaction) {
		this.merchantTransaction = merchantTransaction;
	}
}